const Mock=require("mockjs");

const findUserList = function() {
    return Mock.mock({
        "list|2":[
            {
                id:"@id",
                name:"@cname",
                "sex|1":["男","女","未知"],
                tel:/^1\d{10}$/,
                img:"https://api.ixiaowai.cn/mcapi/mcapi.php?_=@id"
            }
        ]
    })
}
const findUserById = function(id="") {
    return Mock.mock({
        id:id,
        name:"@cname",
        "sex|1":["男","女","未知"],
        tel:/^1\d{10}$/,
        img:"https://api.ixiaowai.cn/mcapi/mcapi.php?_=@id"
    })
}

const findStudentById = function(id=""){
    if(id=="100001"){
        return Mock.mock({
            id:id,
            name:"张三",
            sex:"男",
            tel:/^1\d{10}$/,
            img:"https://api.ixiaowai.cn/mcapi/mcapi.php?_=@id"
        })
    }else if(id=="100002"){
        return Mock.mock({
            id:id,
            name:"李四",
            sex:"女",
            tel:/^1\d{10}$/,
            img:"https://api.ixiaowai.cn/mcapi/mcapi.php?_=@id"
        })
    }else{
        return {};
    }
}


module.exports = {
    Random:Mock.Random,
    findUserList,findUserById,findStudentById
}